import { FC } from "react";
import style from "./index.module.scss"
import AForm from "../../compent/AForm";
import { AformConfig } from "./config/index"
import { auth } from "../../untils/api"
import { useDispatch } from "react-redux";
import { getuserdata } from "../../store/action"
// import { Navigate } from "react-router-dom";
import { useNavigate } from "react-router-dom";


const Login: FC<{}> = () => {
    const navigate=useNavigate()
    //实例disoatch
    const disoatch = useDispatch()
    //实例路由
    const loginbtn = (data: any) => {
        console.log(data)
        auth.loginUser(data).then(res => {
            if(res.data.statusCode==200){
                localStorage.setItem("user", JSON.stringify(res.data.data))
            }
            //纯本地
           
            //存仓库
            // disoatch(getuserdata(res.data.data))
            // History.push("/")
            navigate("/home")
            
        })
    }
    return (
        <div className={style["login-wrap"]}>
            <div className={style["login-wrap-kuang"]}>
                <div className={style["login-wrap-box"]}>图片</div>
                <div className={style["login-wrap-box"]}>
                    <AForm layout="horizontal" AformConfig={AformConfig} onsubmit={loginbtn}></AForm>
                </div>
            </div>
        </div>
    )
}

export default Login